 	set more off
capture log close
capture clear all
*log using National_banks_crisis5.log, text replace
set memory 200m

/***!***!***!***!***!*** [National_banks_crisis_2018_b.do ] ***!***!***!***!***!
*
* Project: National Banks  		
* Programmer:  Scott Fulford, 
*
* Date:    	 May 2018
*
* Auditor:      
* Audit Date:   
*
* Purpose:      
* 1) Compare gold assets and specie holdings of state and national banks
* 2) Create a measure of state bank importance by state to use as control
* 3)
* 		      
*
* Ouputs: 
*		
* Sources: Flood, Mark D.  U.S. HISTORICAL DATA ON BANK MARKET STRUCTURE, 1896-1955
[Computer file].  Charlotte, NC:  Mark D. Flood [producer], 1998.  Ann
Arbor, MI: Inter-university Consortium for Political and Social Research
[distributor], 1998.

*
***!***!***!***!***!***!***!***!***!***!***!***!***!***!***!***!***/


/***Define Global Directory ****/
//Change rootdir to where store files
	global ROOTDIR "F:/Dropbox/national banks peg/Replication_files"
	local PROGDIR  "$ROOTDIR"
	local INDIR  "$ROOTDIR/data"
	local OUTDIR  "$ROOTDIR/data"
/*******************************/

cd "`INDIR'/bankdata-hist_text"

/*
//Entered from 1893 Report of the comptroller of the currency
import excel "BANKDATA.xlsx", sheet("state") firstrow
tempfile state1893_1888
save `state1893_1888'

//Load state assets from earlier years
append using `state1893_1888'
*/


//Data read into excel first to convert easily into from fixed format
import excel "BANKDATA.xlsx", sheet("Sheet1") firstrow clear	


twoway (scatter N_COIN S_COIN if YEAR ==1896)
twoway (scatter N_COIN S_COIN if YEAR ==1896), xscale(log) yscale(log)
gen f_coin = N_COIN/N_TOTASS
gen f_N_COIN = N_COIN/N_TOTASS
gen S_TOTASS=A_TOTASS-N_TOTASS //Note: not Total assets - National asset is not quite state assets, although
//close in most states


gen f_S_COIN = S_COIN/S_TOTASS

gen TOTASS = S_TOTASS+N_TOTASS
gen f_state = S_TOTASS/TOTASS

twoway ///
	(scatter f_S_COIN f_N_COIN  if YEAR ==1896 [w=TOTASS], mcolor(gs13)  ) ///
	(scatter f_S_COIN f_N_COIN  if YEAR ==1896 [w=TOTASS],  msymbol(i)  mlabel(ST) mlabp(0) mlabcolor(navy)) ///
	(lfit f_S_COIN f_N_COIN  if YEAR ==1896), ///
	xlabel(0(.05).2) ylabel(0(.05).2) ///
	 xtitle(Fraction currency or coin in national banks) ///
	 ytitle(Fraction currency or coin in state banks) legend(off) ///
	 name(national_state_coin_1896, replace)

  cd "`OUTDIR'"
  graph export national_state_coin_1896.pdf,  as(pdf) name(national_state_coin_1896) font(times) replace 


reg f_S_COIN f_N_COIN [w=f_state] if YEAR == 1896

cd "`INDIR'"
rename YEAR year
save all_bank_data, replace


